package br.iars.model.entity;

import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "user")
@AttributeOverride(name = "id", column = @Column(name = "user_id"))
public class User extends GenericEntity<Long> {

	private static final long serialVersionUID = -5160067409381049927L;

	@Column(name = "email", length = 100, nullable = false)
	private String email;

	@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
	private List<Preference> preferences;

	public User() {
		super();
	}

	public User(Long id) {
		super(id);
	}

	public User(String email) {
		super();
		this.email = email;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public List<Preference> getPreferences() {
		return preferences;
	}

	public void setPreferences(List<Preference> preferences) {
		this.preferences = preferences;
	}

	@Override
	public String toString() {
		return "User [email=" + email + ", preferences=" + preferences + ", getId()=" + getId() + "]";
	}

}
